﻿using Common.Tools;
using Core.Info;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core.Utility.Helper
{
    /// <summary>
    /// 随机值助手类
    /// </summary>
    public static class RandomValueHelper
    {
        /// <summary>
        /// 获取随机请求Id
        /// </summary>
        public static string RandomRequestId
        {
            get
            {
                string md5Random = $"{UserInfo.UseTenantSid}" +
                    $"{UserInfo.AccountSid}" +
                    $"{UserInfo.UseDeptSid}" +
                    $"{ComputerInfoHelper.GetMachineName()}" +
                    $"{string.Join("|", ComputerInfoHelper.GetIpAddress())}" +
                    $"{Guid.NewGuid()}" +
                    $"{DateTimeHelper.ToUnixTime13Bit(AppTime.Now)}";
                string md5 = CryptoFactoryHelper.MD5(md5Random, nameof(RandomRequestId), 4);
                return md5;
            }
        }
    }
}
